<template>
	<view>
		<view>
			<navbar  title="店铺列表" :isGoBack="true" :isNotice="true" ></navbar>
		</view>		
        <view class="node-tab">
            <view class="tab-item"  :class="[currentTab == 4 ? 'active' : '']" :data-current="4" @click="changeNav">线下店铺</view>
            <view class="tab-item"  :class="[currentTab == 3 ? 'active' : '']" :data-current="3" @click="changeNav">店铺收入</view>
        </view>		
		<view>
		  <swiper class="tab-content"  duration="300" bindchange="changeTab" :style="{'height':winHeight+'px'}">
				<!-- 全部 -->
				<swiper-item>
					<scroll-view :scroll-y="true" class="new-list-box" @scrolltolower="allLoadMore" scroll-top="scrollTop" scroll-with-animation :refresher-enabled="true" refresher-threshold="80" refresher-default-style="white" refresher-background="white" :refresher-triggered="triggered" @refresherrefresh="onAllRefresh">
						<block v-if=" currentTab == 3 && allTabList.length > 0">
						  <view class="new-list-item" v-for="(item,index) in allTabList" :key="index">   
							 <view class="item-tag dis-flex-between">                    
								 <view class="content-deadline mb-15 text-xsl">交易时间：{{item.add_time}}</view>
								 <view class="content-deadline">类型：{{item.moneyType_name}}</view>                            
							 </view>
							 <view class="item-tag dis-flex-between">
							   <view class="content-deadline mb-15" style="color: red;font-weight: bold;font-size: 28rpx;" v-if="item.style == '1'">+ {{item.affectMoney}}</view>
							   <view class="content-deadline mb-15" style="color: gray;font-weight: bold;font-size: 28rpx;" v-if="item.style == '0'">- {{item.affectMoney}}</view>
							 <view class="content-deadline">余额：{{item.accountMoney}}</view>
						   </view>
						  </view>
						</block>  
						
						<block v-if="currentTab == 4 && allTabList.length > 0">						 
						    <view class="one_mian" v-for="(item,index) in allTabList" :key="index">
						         <view class="mian_left">
						            <text class="mt-20 text-lg text-bold">{{item.storage_shop_name}}</text>
						            <view class="mt-15 flex">
						               <view class="main_tag" style="background: #2B91ED;;margin-right: 10rpx;"><text>可外卖</text></view>
						               <view class="main_tag" style="background: #2B91ED;"><text>可自取</text></view>
						            </view>
						            <view class="mt-15 text-xs flex flex-direction">
						            <view><van-icon name="location-o" size="35rpx" /><text class="ml-10">{{item.province}}{{item.city}}{{item.area}}{{item.address}}</text></view>
						            <view class="mt-15"> <van-icon name="clock-o" size="35rpx"  /><text class="mt-15 ml-10">00:00-23:00</text></view>
						            </view>
						            <view class="mt-15 mb-20 flex">
										<view class="flex mr-15">										   
										  <u-tag class="tag" plain size="mini" style="font-size: 3rpx;width: 110rpx;"  text="营业中"></u-tag>
										</view>
										<view class="flex">	
										   <u-tag class="tag" plain size="mini" style="font-size: 3rpx;width: 130rpx;" type="success"  text="接受预定"></u-tag>
										</view>										
						            </view>
						         </view>
						         <view style="border-right: 1px solid #e2dede; margin-top: 30rpx; margin-bottom: 30rpx;margin-left: 10rpx;"></view>
						         <view class="mian_right">						         
						          <text class="text-bold" style="font-size: 25rpx;color: red;">￥{{item.money}}</text>
						          <text style="font-size: 30rpx;margin-top:20rpx;">店铺收益</text>					  
						         </view>
						      </view>   
						</block>																	  
					</scroll-view>
				</swiper-item>       
			</swiper>				
		</view>	
	</view>	
</template>
<script>
	export default {
			data() {
				return {
					currentTab:4,
					pageNo:1,
					allTabList:[],
					winHeight:'',
					scrollTop: 0, // 设置竖向滚动条位置
					triggered: false, // 下拉是否激活
					recordCount:1,
					infoType:1
				}
			},
			onLoad(options) {
				let height = uni.getSystemInfoSync().windowHeight;
				this.winHeight = (height - 150);			
				this._requestPageList(true);
				if(options.type){
				    this.infoType=options.type
				}
			},
			methods:{
				changeNav(e){
					let currentIndex = e.target.dataset.current;
					if (this.currentTab == currentIndex) {      
					    return false;
					} else {
					    this.pageNo=1;
						this.currentTab= currentIndex
					}
					this.allTabList=[];
					this._requestPageList(true);
				},			
				
				// 参数
				_requestPageList(isLoadMore = false, callback) {
				  if(!isLoadMore){
					this.allTabList=[]; // 全部       
					this.pageNo= 1;
					
				  }
				  let opt = {
					pageNo :this.pageNo,				
					token:uni.getStorageSync('userInfo').app_openid,
					login_type:'app',
					status:this.currentTab,
					infoType:this.infoType
				  }    
				  this._requestPageListCom("virtualTaskList", opt, callback);
				},
				// 列表接口
				_requestPageListCom(url, params, callback) {    
				  this.$http.moneylog_list(params).then(res => {
					if (res.resCode == "9999") {
					  let oldList = [];
					  oldList = this.allTabList;       
					  const newGoodsList = res.data.list
					  const allData = [...oldList, ...newGoodsList]
					  // console.log(allData,'allData')     
					  this.allTabList=allData
					  this.recordCount=res.data.page
					  if(callback && typeof callback === 'function'){
						callback()
					  }
					}
				  })
				},			  
				// 上拉加载  滚动到底部/右边时触发
				allLoadMore(e){
					let _self = this;
					if (this._allLoadMore) return
					this._allLoadMore = true;
					this.pageNo= ++_self.pageNo				
					this._requestPageList(true, () => {
					  _self._allLoadMore = false;
					});
				},
				
				// 下拉刷新接口
				onAllRefresh() {
				 // 开启下拉自定义样式
					this.triggered = true;
		            this.pageNo=1;
					this._requestPageList(false, () => {
						// 当处理完数据刷新后，wx.stopPullDownRefresh可以停止当前页面的下拉刷新
						this.triggered = false;
					});    
				}				
			}
		}
</script>

<style>
	@import "./index.css";
</style>